<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8"></meta>
		<title>网关配置</title>
		<meta name="renderer" content="webkit"></meta>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"></meta>
		<link rel="stylesheet" href="../../css/font.css"></link>
		<link rel="stylesheet" href="../../css/weadmin.css"></link>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	    
	    <script src="../../js/jquery-3.1.1.js"></script>
	    <script type="text/javascript" src="../../js/admin.js"></script>
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="">节点管理</a>
        <a>
          <cite>网关配置</cite></a>
      </span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">&#x1002;</i></a>
		</div>
		<div class="weadmin-body">
			
			<div class="weadmin-block">
				可以动态配置各网关节点所开启的规约类型，开启之后可以通过模拟终端测试网关链路。规约配置请到“规约维护”页面操作。
				<span class="fr"  id ="totle">节点总数：0 个</span>
			</div>
			<table class="layui-table" id="memberList">
				<thead>
					<tr>
						<th>
							<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
						</th>
						<th>主机IP</th>
						<th>规约编号</th>
						<th>运行状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id ="table_brian">
					<!-- 
					<tr data-id="1">
						<td>
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="1"><i class="layui-icon">&#xe605;</i></div>
						</td>
						<td>127.0.0.1</td>
						<td>1,2,3</td>
						<td class="td-status">
							<span class="layui-btn layui-btn-normal layui-btn-xs">正常</span></td>
						<td class="td-manage">

							<a title="编辑" onclick="WeAdminEdit('编辑','./edit.html', 1, 600, 400)" href="javascript:;">
								<i class="layui-icon">&#xe642;</i>
							</a>
							
							<a title="查看" onclick="WeAdminDetail('查看','../admin/view.html', 1, 600, 400)" href="javascript:;">
								<i class="layui-icon">&#xe63c;</i>
							</a>
						</td>
					</tr>
					-->
				</tbody>
			</table>
			
		</div>
		<!--<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>-->
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script src="../../js/eleDel.js" type="text/javascript" charset="utf-8"></script>
	</body>
	<script type="text/javascript">
	
	$(function(){
		$.post("/rpc/gateData", function(data){
				debugger;
			var arrayData = data.data;
			var str = ""; 
			for(var i = 0 ; i< arrayData.length ; i ++){
				arrayData[i].ip;
				arrayData[i].data;
				arrayData[i].stat;
				
				str +=
				"<tr data-id=\""+i+"\">\n" +
				"	<td>\n" +
				"		<div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id=\"1\"><i class=\"layui-icon\">&#xe605;</i></div>\n" +
				"	</td>\n" +
				"	<td>"+arrayData[i].ip+"</td>\n" +
				"	<td>"+(arrayData[i].data == null ? "无"  : arrayData[i].data) +"</td>\n" +
				"	<td class=\"td-status\">\n" ;
				if(arrayData[i].stat == "ok"){
					str += "<span class=\"layui-btn layui-btn-normal layui-btn-xs\">正常</span></td>\n" ;
				}else{
					str += "<span class=\"layui-btn layui-btn-danger layui-btn-xs\">异常</span></td>\n" ;
				}
				str +=
				"	<td class=\"td-manage\">\n" +
				"		<a title=\"编辑\" onclick=\"WeAdminEdit2('编辑','./edit.html', '"+arrayData[i].ip+"','"+arrayData[i].data+"', 600, 400)\" href=\"javascript:;\">\n" +
				"			<i class=\"layui-icon\">&#xe642;</i>\n" +
				"		</a>\n" +
				"	</td>\n" +
				"</tr>";
			}
			$("#table_brian").append(str);
			$("#totle").html("节点总数："+arrayData.length+"个");
	       	
	    });
		
	})
	/*
		自我改造：弹出层+传递参数
	*/
	window.WeAdminEdit2 = function(title, url, ip,strategy, w, h) {
		if(title == null || title == '') {
			title = false;
		};
		if(url == null || url == '') {
			url = "404.html";
		};
		if(w == null || w == '') {
			w = ($(window).width() * 0.9);
		};
		if(h == null || h == '') {
			h = ($(window).height() - 50);
		};
		layer.open({
			type: 2,
			area: [w + 'px', h + 'px'],
			fix: false, //不固定
			maxmin: true,
			shadeClose: true,
			shade: 0.4,
			title: title,
			content: url,
			success: function(layero, index) {
				//向iframe页的id=house的元素传值  // 参考 https://yq.aliyun.com/ziliao/133150
				var body = layer.getChildFrame('body', index);
				body.contents().find("#nodeIP").val(ip);//ip赋值
				var arra01 = strategy.split("/");
				var datas = [];
				for(var i = 0 ;i< arra01.length-1 ; i++){
					datas.push(arra01[i].split(":")[0].trim());
				}
				
				var iframe = window['layui-layer-iframe' + index];
                // 向子页面的全局函数child传参
                iframe.child(datas);
			},
			error: function(layero, index) {
				alert("aaa");
			}
		});
	}	
	</script>

</html>